// rolagem pelas setas do teclado
function scrollToPrior () {
		scrollTop = $(window).scrollTop();
		var scrollToThis = null;
		
		$('.conteudo,.topo').each(function(i, h2){ // loop through article headings
			h2top = $(h2).offset().top-46; // get article heading top
			if (scrollTop > h2top) { // compare if document is below heading
				scrollToThis = h2top;
			} else {
				return false;	
			}
		});
		
		if (scrollToThis != null) {
			$('html,body').animate({scrollTop: scrollToThis},'slow');
		}
}

function scrollToNext () {
		scrollTop = $(window).scrollTop();
		$('.conteudo').each(function(i, h2){ // loop through article headings
			h2top = $(h2).offset().top-46; // get article heading top
			if (scrollTop < h2top) { // compare if document is below heading
				$('html,body').animate({scrollTop: h2top},'slow');
				return false;
			}
		});
	}

jQuery(function () {
	$(document).keydown(function (evt) {
		switch (evt.keyCode) {
		
			case 37:  // seta esquerda
				evt.preventDefault(); // prevents the usual scrolling behaviour
				scrollToPrior();
				break;
				
			case 39:  // seta direita
				evt.preventDefault(); // prevents the usual scrolling behaviour
				scrollToNext();
				break;
		}
	});

});

// rolagem pelos links do menu
$(document).ready(function() {
	$("nav.menu a, .titulo").click(function(event) {
		event.preventDefault();
		$('body').animate({scrollTop: $($(this).attr('href')).offset().top-46}, 'slow');
	});
});

// carrossel de fotos
$(function() {
	$("div#controller").jFlow({
		slides: "#slides",
		//width: "980px",
		width: "700px",
        height: "313px"
	});
});